﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;

namespace PefStudio.Windows
{
    [Export(MainWindow.RibbonMenusContract, typeof(IRibbonBackstage))]
    class Backstage : AbstractRibbonBackstage
    {
        public const string Contract = "Backstage";

        public Backstage()
        {
            BaseContract = Contract;

            Background = Brushes.Green;
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public class SaveRibbonButton : AbstractRibbonButton
    {
        public SaveRibbonButton()
        {
            Header = "Save";
            ID = "Save";

            Icon = @"Images\Save.png";
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public class SaveAsRibbonButton : AbstractRibbonButton
    {
        public SaveAsRibbonButton()
        {
            Header = "Save As";
            ID = "SaveAs";

            Icon = @"Images\Save.png";
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public partial class InfoRibbonBackstageTabItem : AbstractRibbonBackstageTabItem
    {
        public InfoRibbonBackstageTabItem()
        {
            Header = "Info";
            ID = "Info";

            InitializeComponent();
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public partial class RecentRibbonBackstageTabItem : AbstractRibbonBackstageTabItem
    {
        public RecentRibbonBackstageTabItem()
        {
            Header = "Recent";
            ID = "Recent";

            InitializeComponent();
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public partial class NewRibbonBackstageTabItem : AbstractRibbonBackstageTabItem
    {
        public NewRibbonBackstageTabItem()
        {
            Header = "New";
            ID = "New";

            InitializeComponent();
        }

        private void OnBlueClick(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (ThreadStart)(() =>
            {
                Application.Current.Resources.BeginInit();
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Blue.xaml") });
                Application.Current.Resources.MergedDictionaries.RemoveAt(0);
                Application.Current.Resources.EndInit();
            }));
        }

        void OnSpinnerValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            // MessageBox.Show(String.Format("Changed from {0} to {1}", e.OldValue, e.NewValue));
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public partial class PrintRibbonBackstageTabItem : AbstractRibbonBackstageTabItem
    {
        public PrintRibbonBackstageTabItem()
        {
            Header = "Print";
            ID = "Print";

            InitializeComponent();
        }
    }

    [Export(Backstage.Contract, typeof(IRibbonChildItem))]
    public partial class ExitRibbonButton : AbstractRibbonButton
    {
        public ExitRibbonButton()
        {
            Header = "Exit";
            ID = "Exit";

            InitializeComponent();
        }
    }

    [Export(MainWindow.RibbonQuickAccessItemsContract, typeof(IRibbonQuickAccessMenuItem))]
    public partial class RibbonQuickAccessMenuItem1 : AbstractRibbonQuickAccessMenuItem
    {
        public RibbonQuickAccessMenuItem1()
        {
            InitializeComponent();
        }
    }
}
